﻿namespace GameToolkit
{
    public enum EThreadTag
    {
        MainThread = 1,
        SubThread = 2,
        AllThread = -1,
    }

    [System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Class)]
    public class InvokeOnThreadAttribute: System.Attribute
    {
        public EThreadTag WorkThread { get; set; }

        public bool IsMainThreadInvoke { get { return (WorkThread & EThreadTag.MainThread) != 0; } }
        public bool IsSubThreadInvoke { get { return (WorkThread & EThreadTag.SubThread) != 0; } }

        public InvokeOnThreadAttribute() { }

        public InvokeOnThreadAttribute(EThreadTag tag)
        {
            this.WorkThread = tag;
        }

    }

    /// <summary>
    /// 线程安全标识
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IThreadSafty<out T>
    {
        T GetSaftyInstance();
    }

}